<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <style>
                fieldset{
                    margin-right: 15px;
                }
            </style>

            <h:form id="userForm" enctype="multipart/form-data">
                <p:panel id="usuarioPanel" styleClass="clearfix container_24 withoutBorder">
                    <h3 class="title">Pesquisar Usuário</h3> <hr/>

                    <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 

                    <p:panel id="filtrosPanel" styleClass="clearfix container_24 withoutBorder">
                        <fieldset>
                            <legend>Pesquisar</legend>
                            <p:outputLabel value="Nome:" styleClass="grid_3"/>
                            <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuarioPesquisar.nome}" />

                            <p:outputLabel value="Profissão:" styleClass="grid_3"/>
                            <p:inputText styleClass="grid_20" value="#{managerPesquisarUsuario.usuarioPesquisar.post}" />

                        </fieldset>
                    </p:panel>

                    <div class="buttonAction">
                        <p:commandButton  id="pesquisarCommandButton" value="Pesquisar" icon="ui-icon-search"
                                          update="@form, tableUser"
                                          actionListener="#{managerPesquisarUsuario.pesquisar()}"
                                          styleClass="ui-priority-primary" />
                        <p:commandButton value="Limpar" update="@form" icon="ui-icon-clean"
                                         actionListener="#{managerPesquisarUsuario.limpar()}" />
                    </div>

                    <p:blockUI id="BLOCK" block="resultPanel" trigger="pesquisarCommandButton, tableUser" > 
                        <p:graphicImage value="/media/images/ajax-loader.gif"/>
                    </p:blockUI>

                    <p:panel id="resultadosPanel" styleClass="clearfix container_24 withoutBorder">
                        <fieldset>
                            <legend>Resultado</legend>
                            <p:panel id="resultPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">

                                <p:dataTable id="tableUser" var="u" value="#{managerPesquisarUsuario.dataModel}" 
                                             styleClass="grid_24" rowIndexVar="rowid"
                                             binding="#{managerPesquisarUsuario.searchResults}"
                                             rows="5" paginator="true" lazy="true"   
                                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                             currentPageReportTemplate="{currentPage} de {totalPages}"
                                             paginatorPosition="bottom" emptyMessage="Nenhum registro encontrado">

                                    <f:facet name="header">
                                        Usuário
                                    </f:facet>
                                    <p:column headerText="Ação" width="75">
                                        <p:button  style="width: 20px; height: 20px;" 
                                                   title="editar"
                                                   href="editarusuario.xhtml?usuarioEditar=#{u.id}"
                                                   icon="ui-icon-pencil"/>
                                        <p:button  style="width: 20px; height: 20px;" 
                                                   title="visualizar"
                                                   href="visualizarusuario.xhtml?usuarioVisualizar=#{u.id}"
                                                   icon="ui-icon-zoomin"/>
                                        <p:button  style="width: 20px; height: 20px;" 
                                                   title="Acesso"
                                                   href="acessuser.xhtml?userAcess=#{u.id}"
                                                   icon="ui-icon-locked"/>
                                    </p:column>
                                    <p:column headerText="Nome" width="600">  
                                        <h:outputText value="#{u.nome}"/>
                                    </p:column>  
                                    <p:column headerText="Login">  
                                        <h:outputText value="#{u.login}"/>
                                    </p:column>

                                </p:dataTable> 

                            </p:panel>

                        </fieldset>
                    </p:panel>

                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
